﻿namespace Chain.BLL
{
    using Chain.IDAL;
    using Chain.Model;
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Runtime.InteropServices;

    public class MicroWebsiteGoodsClass
    {
        private readonly Chain.IDAL.MicroWebsiteGoodsClass dal = new Chain.IDAL.MicroWebsiteGoodsClass();

        public int Add(Chain.Model.MicroWebsiteGoodsClass model)
        {
            return this.dal.Add(model);
        }

        public List<Chain.Model.MicroWebsiteGoodsClass> DataTableToList(DataTable dt)
        {
            List<Chain.Model.MicroWebsiteGoodsClass> list = new List<Chain.Model.MicroWebsiteGoodsClass>();
            int count = dt.Rows.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Chain.Model.MicroWebsiteGoodsClass item = new Chain.Model.MicroWebsiteGoodsClass();
                    if ((dt.Rows[i]["MicroGoodsClassID"] != null) && (dt.Rows[i]["MicroGoodsClassID"].ToString() != ""))
                    {
                        item.MicroGoodsClassID = int.Parse(dt.Rows[i]["MicroGoodsClassID"].ToString());
                    }
                    if ((dt.Rows[i]["MicroGoodsClassName"] != null) && (dt.Rows[i]["MicroGoodsClassName"].ToString() != ""))
                    {
                        item.MicroGoodsClassName = dt.Rows[i]["MicroGoodsClassName"].ToString();
                    }
                    if ((dt.Rows[i]["MicroGoodsClassRemark"] != null) && (dt.Rows[i]["MicroGoodsClassRemark"].ToString() != ""))
                    {
                        item.MicroGoodsClassRemark = dt.Rows[i]["MicroGoodsClassRemark"].ToString();
                    }
                    if ((dt.Rows[i]["MicroGoodsClassShopID"] != null) && (dt.Rows[i]["MicroGoodsClassShopID"].ToString() != ""))
                    {
                        item.MicroGoodsClassShopID = int.Parse(dt.Rows[i]["MicroGoodsClassShopID"].ToString());
                    }
                    list.Add(item);
                }
            }
            return list;
        }

        public bool Delete(int MicroGoodsClassID)
        {
            return this.dal.Delete(MicroGoodsClassID);
        }

        public bool DeleteList(string MicroGoodsClassIDlist)
        {
            return this.dal.DeleteList(MicroGoodsClassIDlist);
        }

        public bool Exists(int MicroGoodsClassID)
        {
            return this.dal.Exists(MicroGoodsClassID);
        }

        public DataSet GetAllList()
        {
            return this.GetList("");
        }

        public DataSet GetGoodsClassInfo(int PageSize, int PageIndex, out int resCount, params string[] strWhere)
        {
            return this.dal.GetGoodsClassInfo(PageSize, PageIndex, out resCount, strWhere);
        }

        public DataSet GetList(string strWhere)
        {
            return this.dal.GetList(strWhere);
        }

        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return this.dal.GetList(Top, strWhere, filedOrder);
        }

        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return this.dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }

        public int GetMaxId()
        {
            return this.dal.GetMaxId();
        }

        public Chain.Model.MicroWebsiteGoodsClass GetModel(int MicroGoodsClassID)
        {
            return this.dal.GetModel(MicroGoodsClassID);
        }

        public List<Chain.Model.MicroWebsiteGoodsClass> GetModelList(string strWhere)
        {
            DataSet list = this.dal.GetList(strWhere);
            return this.DataTableToList(list.Tables[0]);
        }

        public int GetRecordCount(string strWhere)
        {
            return this.dal.GetRecordCount(strWhere);
        }

        public bool Update(Chain.Model.MicroWebsiteGoodsClass model)
        {
            return this.dal.Update(model);
        }
    }
}

